<!DOCTYPE HTML>
<html>
<head>
    <meta charset=utf-8>
    <meta name1="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1"/>
    <link href="css/style.css" rel="stylesheet"/>
    <title>个人信息</title>
</head>
<body>
<div id="head">
    <div class="memu">
        <div class="logo"><img src="images/logo.ico"></div>
        <div class="nav">
            <ul class="nav_firstul">
                <li><a href="home.html">首页</a></li>
                <li><a href="xtgg.html">系统公告</a></li>
                <!-- <li><a href="">论坛与帮助</a></li>  -->
            </ul>
        </div>
        <div class="loginse">
            <a href="login.html">登录</a> &nbsp;&nbsp;|&nbsp;&nbsp;
            <a href="register.html">注册</a>
        </div>
    </div>

</div>
<div id="con1">
    <form type="post" id="subForm" name="subForm" action="/open/oauth/dev/app/editUserInfo.action">
        <div class="solidnav1">
            <ul>
                <li class="solidnav_list1"><a href="personal_inform.htm">基本资料</a></li>
                <li class="solidnav_list1"><a href="personal_password.htm">修改密码</a></li>
            </ul>
        </div>
        <div class="con_text">
            <div class="personal_inform">
                <div class="p_title"><span class="truename">会员用户基本信息</span></div>
                <div class="name1">
                    <div class="n_right">
                        <input type="text" class="n_input" name="userName" id="username" placeholder="请填写您的真是姓名,便于和您沟通">
                        <div class="errorTips"></div>
                    </div>
                    <div class="n_title">真实姓名</div>
                </div>

                <div class="name1">
                    <div class="n_right">
                        <input type="text" class="n_input" name="companyname" id="companyname"
                               placeholder="请填写您公司的名称全称">
                        <div class="errorTips"></div>
                    </div>
                    <div class="n_title">公司名称</div>
                </div>

                <div class="name1">
                    <div class="n_right">
                        <input type="text" class="n_input" name="mobile" id="mobile" placeholder="请填写您的联系电话，便于和您沟通">
                        <div class="errorTips"></div>
                    </div>
                    <div class="n_title">联系电话</div>
                </div>
                <div class="name1">
                    <div class="n_right">
                        <input type="text" class="n_input" name="address" id="address" placeholder="请填写您公司所在地址">
                        <div class="errorTips"></div>
                    </div>
                    <div class="n_title">联系地址</div>
                </div>
            </div>
            <div class="two_button">
                <input type="submit" class="button1" style="border:0px;cursor:pointer;" value=" 提 交 "></input>
                <input id="btn_cancel" type="button" class="button2" style="border:0px;cursor:pointer;"
                       value=" 取 消 "></input>
            </div>
        </div>
    </form>
</div>
<div id="footer">
    <div class="foot">
        <p class="copyright">© 2019 Web Book Store Management platform.</p>
        <p class="footlike"><a href="user_xy.html">用户协议</a> &nbsp; | &nbsp;  <a href="">联系我们</a>
        </p>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/assets/js/template.js"></script>
<script type="text/javascript" src="js/init.js"></script>
<script type="text/javascript" src="/static/assets/js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/additional-methods.js"></script>
<script type="text/javascript" src="/static/assets/js/jquery.form.js"></script>
<script type="text/javascript" src="/static/plugins/layer/layer.js"></script>

<script type="text/javascript">
    $(function () {
        $("#btn_cancel").click(function () {
            window.location.href = "index.html";
        });

        //获取用户信息
        $.ajax({url: "/open/oauth/dev/loginState.action", cache: false}).done(function (data) {
            $("#username").val(data.username);
            $("#mobile").val(data.user.mobile);
            var address = data.user.address;
            $("#address").val(address);
            $("#companyname").val(data.user.companyname);
        });

        $("#subForm").validate({
            //errorClass: "label.error", //默认为错误的样式类为：error
            focusInvalid: false, //当为false时，验证无效时，没有焦点响应
            //onkeyup: false,
            submitHandler: function (form) {   //表单提交句柄,为一回调函数，带一个参数：form
                jQuery(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.result) {
                            layer.alert("修改成功!", {
                                icon: 1,
                                title: "信息",
                                yes: function () {
                                    window.location.href = "index.html";
                                }
                            });
                        } else {
                            //$("#error-message").css({"display": "block"}).find("span").text(data.message);
                            layer.alert(data.message, {icon: 2, title: "错误信息"});
                            return false;
                        }
                    },
                    error: function () {
                        layer.alert("网络异常,请稍候再试", {icon: 2, title: "错误信息"});
                    }
                });
            },
            errorPlacement: function (error, element) {
                console.log(element);
                error.appendTo(element.next("div"));
            },
            rules: {
                userName: {
                    required: true,
                    rangelength: [2, 10]
                },
                mobile: {
                    required: true,
                    phone: true
                },
                address: {
                    required: true,
                    rangelength: [2, 80]
                },
                companyname: {
                    required: true
                }
            },
            messages: {
                userName: {
                    required: "请输入您的真实姓名!",
                    rangelength: "姓名格式不正确!"
                },
                mobile: {
                    required: "请输入您的联系电话!",
                    phone: "联系电话格式不正确!"
                },
                address: {
                    required: "请输入您的联系地址!",
                    rangelength: "输入的地址格式不正确!"
                },
                companyname: {
                    required: "请输入您的公司姓名!"
                }
            }
        });

    });
</script>
</html>